﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" >
<title>Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Free HTML5 Template by FreeHTML5.co" />
<meta name="keywords" content="free html5, free template, free bootstrap, html5, css3, mobile first, responsive"/>
<!-- Facebook and Twitter integration -->
<meta property="og:title" content=""/>
<meta property="og:image" content=""/>
<meta property="og:url" content=""/>
<meta property="og:site_name" content=""/>
<meta property="og:description" content=""/>
<meta name="twitter:title" content="" />
<meta name="twitter:image" content="" />
<meta name="twitter:url" content="" />
<meta name="twitter:card" content="" />
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="shortcut icon" href="favicon.ico">


<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/animate.css">
<link rel="stylesheet" href="./css/style.css">
<script type="text/javascript" src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<!-- Modernizr JS -->
<script src="./js/modernizr-2.6.2.min.js"></script>
<!-- FOR IE9 below -->
<!--[if lt IE 9]>
<script src="./js/respond.min.js"></script>
<![endif]-->
<script  type="text/javascript">
    $(document).ready(function() {
        load();
    });
    var email;
    var passwd;
    var remb;
    //设置cookie
    function setCookie(name,value,day){
        var date = new Date();
        date.setDate(date.getDate() + day);
        document.cookie = name + '=' + value + ';expires='+ date;
    };
    //获取cookie
    function getCookie(name){
        var reg = RegExp(name+'=([^;]+)');
        var arr = document.cookie.match(reg);
        if(arr){
            return arr[1];
        }else{
            return '';
        }
    };
    function load(){
        email=document.getElementById("useremail");
        passwd=document.getElementById("userpwd");
        remb = document.getElementById("save_me");
        //页面初始化时，如果帐号密码cookie存在则填充
        if(getCookie('useremail') && getCookie('userpwd')){
            email.value = getCookie('useremail');
            passwd.value = getCookie('userpwd');
            remb.checked = true;
        }

    }
    function exist() {
        if(remb.checked){
            setCookie('useremail',email.value,7); //保存帐号到cookie，有效期7天
            setCookie('userpwd',passwd.value,7); //保存密码到cookie，有效期7天
        }
        $.ajax({
            type: "post",
            url: "../user/exist",
            data: {
                e: email.value,
                p: passwd.value,
            },
            datatype:"text",
            success: function(data) {
                if(data=="success")
                    window.location.href = "main.jsp";
                if(data=="false")
                    alert("用户名或密码错误");
            },
            error:function (data) {
                alert("操作失败")
            }
        });
    }

</script>
</head>

<body class="style-3">
<div class="container">
    <div class="row">
        <div class="col-md-4 col-md-push-8">
            <!-- Start Sign In Form -->
            <form class="fh5co-form animate-box" data-animate-effect="fadeInRight">
                <h2>登 录</h2>
                <div class="form-group">
                    <label for="useremail" class="sr-only">请输入邮箱：</label>
                    <input type="text" class="form-control" id="useremail" placeholder="Email" >
                </div>
                <div class="form-group">
                    <label for="userpwd" class="sr-only">请输入密码：</label>
                    <input type="password" class="form-control" id="userpwd" placeholder="Password" >
                </div>
                <div class="form-group">
                    <label for="save_me"><input type="checkbox" id="save_me">记住密码</label>
                </div>
                <div class="form-group">
                    <p>还没有账号？<a href="register.html">注 册</a> | <a href="forgot.html">忘记密码？</a></p>
                </div>
                <div class="form-group">
                    <input type="button" value="登 录" class="btn btn-primary" onclick="exist()">
                </div>
            </form>
            <!-- END Sign In Form -->
        </div>
    </div>
</div>
<!-- jQuery -->
<script src="./js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="./js/bootstrap.min.js"></script>
<!-- Placeholder -->
<script src="./js/jquery.placeholder.min.js"></script>
<!-- Waypoints -->
<script src="./js/jquery.waypoints.min.js"></script>
<!-- Main JS -->
<script src="./js/main.js"></script>
</body>
</body></html>